package com.jgp.sys.service;

import com.jgp.attachment.props.AttachmentConfigPropBean;
import com.jgp.common.utils.JGPUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目   sys
 * 作者   loufei
 * 时间   2018/4/3
 */
@Service
public class ConfigService {
    
    @Value("${server.servlet.context-path}")
    private String contextPath;
    
    private AttachmentConfigPropBean attachmentConfigPropBean;
    
    private static Map<String,Object> onceConfig = new HashMap<>();
    
    public Map<String, Object> getOnceConfig() {
        onceConfig.clear();
        return onceConfig;
    }
    
    public Map<String,Object> globalConfig(){
        Map<String,Object> config = new HashMap<>();
        Map<String,Object> prop = new HashMap<>();
        prop.put("attachment",attachmentConfigPropBean);
        prop.put("onceConfig",onceConfig);
        config.put("prop", JGPUtil.encodeBase64(JGPUtil.encodeBase64(JGPUtil.toJson(prop))));
        config.put("contextPath",contextPath);
        return config;
    }
    
}
